<%@ page contentType="text/html; charset=UTF-8"%>
<%@page import="edu.ccut.saturn.component.SaturnData"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/extjs/include/all.jsp"%>
<title></title>
<script type="text/javascript">
var xml_key = '<%=request.getParameter("process_xml_key")%>';
Ext.onReady(function(){
var resultWidth = Ext.get("process-grid").getWidth();
   if(xml_key=='null' || xml_key==''){
   		xml_key = '${process_xml_key}'
   }
	var process_xml_key = new Ext.form.Hidden({  
			   id:'xml_key',
               name:'xml_key',
               value:xml_key
           });  
	var store1 = new Ext.data.JsonStore({
		    url: '${pageContext.request.contextPath}/edu.ccut.saturn.workflow.manager::/releaseManagerModule/action/QueryProDefineByName.action',
		    root: 'result',
		    fields: [
	               {name: 'process_define_id', mapping: 'process_define_id'},
	               {name: 'process_xml_key', mapping: 'process_xml_key'},
	               {name: 'name', mapping: 'name'},
	               {name: 'version', mapping: 'version'},
	               {name: 'author', mapping: 'author'},
	               {name: 'state', mapping: 'state'}
	           ]
		});
	 store1.load({params: {start:0,limit:20,state:1,process_xml_key:process_xml_key.getValue()}});
	 var grid = new Ext.grid.GridPanel({
	    	frame:true,
	        title: '已发布的流程版本',
       	    store: store1,
       	    height:120,
       	    bodyStyle:'width:100%',
	        columns: [	 
	            {header: "操作",width:resultWidth*0.1,dataIndex: 'process_define_id', sortable: true,renderer:function(value){
	            		return "<a href='${pageContext.request.contextPath}/edu.ccut.saturn.workflow.manager::/releaseManagerModule/action/CancelReleasePro.action?process_define_id="+value+"&state=0'>"+"取消发布"+"</a>";
	             }},
	            {header: "流程定义ID",width:resultWidth*0.1,dataIndex: 'process_define_id', sortable: true},
	            {header: "流程定义名称",width:resultWidth*0.3,dataIndex: 'process_xml_key', sortable: true},
	            {header: "流程名称",width:resultWidth*0.1, dataIndex: 'name', sortable: true},
	            {header: "流程版本号",width:resultWidth*0.1, dataIndex: 'version', sortable: true},
	            {header: "流程定义者",width:resultWidth*0.1, dataIndex: 'author', sortable: true},
	            {header: "流程发布状态",width:resultWidth*0.1, dataIndex: 'state', sortable: true,renderer:showState}
	        ],
	        renderTo:'process-grid',
	        frame:true,
	        loadMask: {msg:'正在加载数据，请稍侯……'},
	         tbar:new Array("->",
			   new Ext.Toolbar.Button({
						   text:'返回',
						   xtype:"button" ,
						   handler:function(){
						   		window.location="${pageContext.request.contextPath}/edu.ccut.saturn.workflow.manager/releaseManagerModule/page/releaseProMgr.jsp";
						   },
						   scope :this})
			 ) 
    });
		
	var store2 = new Ext.data.JsonStore({
	    url: '${pageContext.request.contextPath}/edu.ccut.saturn.workflow.manager::/releaseManagerModule/action/QueryProDefineByName.action',
	    root: 'result',
	    totalProperty:'count',
	    fields: [
               {name: 'process_define_id', mapping: 'process_define_id'},
               {name: 'process_xml_key', mapping: 'process_xml_key'},
               {name: 'name', mapping: 'name'},
               {name: 'version', mapping: 'version'},
               {name: 'author', mapping: 'author'},
               {name: 'state', mapping: 'state'}
           ]
	});
	 store2.load({params: {start:0,limit:20,state:0,process_xml_key:process_xml_key.getValue()}});
	 var grid = new Ext.grid.GridPanel({
	    	frame:true,
	        title: '未发布的流程版本',
       	    store: store2,
       	    bodyStyle:'width:100%',
	        columns: [	 
	        	 {header: "操作",width:resultWidth*0.1,dataIndex: 'process_define_id', sortable: true,renderer:function(value){
	            			return "<a href='${pageContext.request.contextPath}/edu.ccut.saturn.workflow.manager::/releaseManagerModule/action/ReleaseProcess.action?process_define_id="+value+"&state=2'>"+"发布"+"</a>";
	             }},
	            {header: "流程定义ID",width:resultWidth*0.1,dataIndex: 'process_define_id', sortable: true},
	            {header: "流程定义名称",width:resultWidth*0.3, dataIndex: 'process_xml_key', sortable: true},
	            {header: "流程名称",width:resultWidth*0.1, dataIndex: 'name', sortable: true},
	            {header: "流程版本号",width:resultWidth*0.1, dataIndex: 'version', sortable: true},
	            {header: "流程定义者", width:resultWidth*0.1,dataIndex: 'author', sortable: true},
	            {header: "流程发布状态",width:resultWidth*0.1, dataIndex: 'state', sortable: true,renderer:showState}
	        ],
	        renderTo:'process-grid',
	        height:330,
	        frame:true,
	        loadMask: {msg:'正在加载数据，请稍侯……'},
	        bbar: new Ext.PagingToolbar({ 
		            pageSize: 20, 
		            store: store2, 
		            displayInfo: true, 
		            displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
		            emptyMsg: "没有数据显示" 
		    }) 
    });
    
    function showState(value){
    	if(value=='1'){
    		return '已发布';
    	}else if(value=='0'){
    		return '未发布';
    	}
    };
})
</script>
</head>
<body>
<div id="process-grid" width="100%"></div>
</body>
</html>